#!/usr/bin/env bash

set -e

echo "---> Add Config"

/usr/local/bin/gen-config-${SEMAPHORE_DB_DIALECT} > /semaphore/.dredd/config.json

echo "---> Waiting for semaphore"
while ! nc -z semaphore_ci 3000; do
  sleep 1
done

echo "---> Run Dredd"
# We do this because otherwise it can fail out
sleep 5
dredd $@
